﻿
Imports ADOEntityAMLO102
Partial Class Form_RptAmlo1_02
    Inherits System.Web.UI.Page

    Dim AmloEntity As AMLO102Entities
    Dim clsDateFormat As New clsDateFormat
    Dim clsMasterDropDown As clsMasterDropDown
    Dim strTempName As String = ""

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache")
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("Expires", "0")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        

        AmloEntity = New AMLO102Entities
        clsMasterDropDown = New clsMasterDropDown
        Dim strRptSeq As String = Request.Item("RptSeq")
        Dim strRptIdx As String = Request.Item("RptIdx")
        'Dim strStatus As String = Request.Item("RPTStatus")
        Try
            'If strStatus = "" Then
            '    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "clientScript", "window.close();", True)

            'Else
            If Not (strRptSeq = "") Then
                Dim sql = (From tblRRPT In AmloEntity.AMLO102 Join tblRRPTDEtail In AmloEntity.AMLODETAIL102 On tblRRPT.RPTSEQ Equals tblRRPTDEtail.RPTSEQ
                        Where tblRRPT.RPTSEQ = strRptSeq And (tblRRPTDEtail.RPTIDX = 1 Or tblRRPTDEtail.RPTIDX = strRptIdx)).ToList
                Dim countRow As Integer = sql.Count

                Dim qryRpt = (From tblRPT In AmloEntity.AMLO102 Where tblRPT.RPTSEQ = strRptSeq).ToList

                Dim qryRptDetail = (From tblRRPTDEtail In AmloEntity.AMLODETAIL102
                                    Where tblRRPTDEtail.RPTSEQ = strRptSeq And (tblRRPTDEtail.RPTIDX = 1 Or tblRRPTDEtail.RPTIDX = strRptIdx)).ToList
                setRptPart1(qryRpt, qryRptDetail)
                setRptPart2(qryRptDetail)

                setRptPart3(qryRpt)

                Response.Write("<script>")
                Response.Write("window.print()")
                Response.Write("</script>")
            End If
            'End If



        Catch ex As Exception

        End Try
      
     
    End Sub


    Private Sub setRptPart1(ByVal RptMaster As IList(Of AMLO102), ByVal RptMasterCus As IList(Of AMLODETAIL102))
        Dim strTemp As String = ""
        Dim arrTemp As String() = Nothing

        'ทำการตัด HGBCode เป็นช่องๆ
        Try


            lblGHBCode1.Text = 0
            lblGHBCode2.Text = 3
            lblGHBCode3.Text = 3
            'ทำการตัด BranchCode เป็นช่องๆ
            strTemp = RptMaster(0).BRANCHCODE
            'branchCode1.Text = subStringText(RptMaster(0).BRANCHCODE, 1)
            'branchCode2.Text = subStringText(RptMaster(0).BRANCHCODE, 2)
            branchCode3.Text = subStringText(RptMaster(0).BRANCHCODE, 1)
            branchCode4.Text = subStringText(RptMaster(0).BRANCHCODE, 2)
            branchCode5.Text = subStringText(RptMaster(0).BRANCHCODE, 3)
            'ทำการตัด lblYear เป็นช่องๆ
            strTemp = RptMaster(0).RPTYEAR
            lblYear1.Text = subStringText(RptMaster(0).RPTYEAR, 1)
            lblYear2.Text = subStringText(RptMaster(0).RPTYEAR, 2)
            'ทำการใส่ค่า rptNo
            lblRptNo.Text = RptMaster(0).RPTNO

            'ทำการ set ค่า RptRev
            If (RptMaster(0).RPTREV = 0) Then
                lblRev0.Text = "x"
                lblRev1.Text = ""
                lblRevOther.Text = "0"
            Else
                lblRev0.Text = ""
                lblRev1.Text = "x"
                lblRevOther.Text = RptMaster(0).RPTREV
            End If


            'เป็นการ set ค่า RPTDate
            Try
                lblRptDate.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).RPTDATE)
            Catch ex As Exception

            End Try




            'เป็นการ set uniqueID
            Dim cusToTran = (RptMasterCus.Where(Function(t) t.RPTIDX = 1)).ToList

            lblUniqueID1.Text = subStringText(cusToTran(0).UNIQUEID, 1)
            lblUniqueID2.Text = subStringText(cusToTran(0).UNIQUEID, 2)
            lblUniqueID3.Text = subStringText(cusToTran(0).UNIQUEID, 3)
            lblUniqueID4.Text = subStringText(cusToTran(0).UNIQUEID, 4)
            lblUniqueID5.Text = subStringText(cusToTran(0).UNIQUEID, 5)
            lblUniqueID6.Text = subStringText(cusToTran(0).UNIQUEID, 6)
            lblUniqueID7.Text = subStringText(cusToTran(0).UNIQUEID, 7)
            lblUniqueID8.Text = subStringText(cusToTran(0).UNIQUEID, 8)
            lblUniqueID9.Text = subStringText(cusToTran(0).UNIQUEID, 9)
            lblUniqueID10.Text = subStringText(cusToTran(0).UNIQUEID, 10)
            lblUniqueID11.Text = subStringText(cusToTran(0).UNIQUEID, 11)
            lblUniqueID12.Text = subStringText(cusToTran(0).UNIQUEID, 12)
            lblUniqueID13.Text = subStringText(cusToTran(0).UNIQUEID, 13)

            If (cusToTran(0).RPTIDXTYPE = 1) Then
                lblRptIdxType1.Text = "x"
            ElseIf (cusToTran(0).RPTIDXTYPE = 2) Then
                lblRptIdxType2.Text = "x"
            End If

            'เป็นการ  set name
            Try
                'If (cusToTran(0).MIDNAME = "-") Then
                '    lblFullName.Text = cusToTran(0).FIRSTNAME & " " & cusToTran(0).LASTNAME
                'Else
                '    lblFullName.Text = cusToTran(0).FIRSTNAME & " " & cusToTran(0).MIDNAME & " " & cusToTran(0).LASTNAME
                'End If


                strTempName = ""
                If Not (cusToTran(0).PREFIX = "-" Or cusToTran(0).PREFIX = Nothing) Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).PREFIX
                    Else
                        strTempName = strTempName + " " + cusToTran(0).PREFIX
                    End If
                End If

                If Not (cusToTran(0).FIRSTNAME = "-" Or cusToTran(0).FIRSTNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).FIRSTNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).FIRSTNAME
                    End If
                End If

                If Not (cusToTran(0).MIDNAME = "-" Or cusToTran(0).MIDNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).MIDNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).MIDNAME
                    End If
                End If

                If Not (cusToTran(0).LASTNAME = "-" Or cusToTran(0).LASTNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).LASTNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).LASTNAME
                    End If
                End If
                lblFullName.Text = strTempName

            Catch ex As Exception
                lblFullName.Text = cusToTran(0).FIRSTNAME & " " & cusToTran(0).LASTNAME
            End Try


            'เป็นการ set formal 
            lblFormalAddr.Text = cusToTran(0).FORMALADDR
            lblFormalPhone.Text = cusToTran(0).FORMALPHONE
            lblFormalFax.Text = cusToTran(0).FORMALFAX

            'เป็นการ set occupation, work
            If (cusToTran(0).OCCUPATIONTYPE = Nothing) Then
                lblOccupationType.Text = ""
            ElseIf (cusToTran(0).OCCUPATIONTYPE = 99) Then
                lblOccupationType.Text = ""

                lblOccupationTypeOther.Text = cusToTran(0).OCCUPATIONTYPEOTHER
                If (cusToTran(0).OCCUPATIONTYPEOTHER.Length > 18) Then
                    lblOccupationTypeOther.Font.Size = FontSize.Small
                End If
            Else
                lblOccupationType.Text = clsMasterDropDown.getOfficeOcc_AMLO102(AmloEntity, cusToTran(0).OCCUPATIONTYPE)
            End If


            lblWorkAddr.Text = cusToTran(0).WORKADDR
            If (cusToTran(0).WORKADDR.Length > 37) Then
                lblWorkAddr.Font.Size = FontSize.Small
            End If
            lblWorkPhone.Text = cusToTran(0).WORKPHONE

            'เป็นการ set สถานที่ติดต่อสะดวก
            lblContactAddr.Text = cusToTran(0).CONTACTADDR
            lblContactPhone.Text = cusToTran(0).CONTACTPHONE
            lblContactFax.Text = cusToTran(0).CONTACTFAX

            'เป็นการ set type หลักฐาน
            Try
                If Not (cusToTran(0).CUSTIDTYPE Is Nothing) Then
                    If (CInt(cusToTran(0).CUSTIDTYPE).ToString = "1") Then
                        lblCustype1.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "6") Then
                        lblCustype1.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "3") Then
                        lblCusType2.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "4") Then
                        lblCusType3.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "99") Then
                        lblCusType4.Text = "x"
                        lblCusTypeOther.Text = cusToTran(0).CUSTIDTYPEOTHER
                    Else
                        lblCusType4.Text = "x"
                        lblCusTypeOther.Text = clsMasterDropDown.getTypeID_AMLO102(AmloEntity, cusToTran(0).CUSTIDTYPE)
                    End If
                End If
            Catch ex As Exception

            End Try


            lblCusId.Text = cusToTran(0).CUSTID
            lblEvby.Text = cusToTran(0).EVBY

            If (cusToTran(0).EVGENTEXT = Nothing) Then
                lblEvGen.Text = ""
            ElseIf (cusToTran(0).EVGENTEXT = "-") Then
                lblEvGen.Text = "-"
            Else
                Try
                    ' lblEvGen.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVGEN)
                    lblEvGen.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVGENTEXT)
                    'ChkConvertIntToDate
                Catch ex As Exception

                End Try
            End If

            If (cusToTran(0).EVEXPIRETEXT = Nothing) Then
                lblEvExpire.Text = ""
            ElseIf (cusToTran(0).EVEXPIRETEXT = "-") Then
                lblEvExpire.Text = "-"
            Else
                Try
                    'lblEvExpire.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVEXPIRE)
                    lblEvExpire.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVEXPIRETEXT)

                Catch ex As Exception

                End Try
            End If
        



        Catch ex As Exception

        End Try


    End Sub

    Private Sub setRptPart2(ByVal RptDetailCus As IList(Of AMLODETAIL102))
        Dim RptDetailCusWhere = RptDetailCus.Where(Function(t) t.RPTIDX <> 1)
        If Not (RptDetailCusWhere.Count = 0) Then


            If (RptDetailCusWhere(0).RPTIDXTYPE = 1) Then
                lblPart2_RptIdxType1.Text = "x"
            ElseIf (RptDetailCusWhere(0).RPTIDXTYPE = 2) Then
                lblPart2_RptIdxType2.Text = "x"
            ElseIf (RptDetailCusWhere(0).RPTIDXTYPE = 3) Then
                lblPart2_RptIdxType3.Text = "x"
            End If

            lblPart2_UniqueId1.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 1)
            lblPart2_UniqueId2.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 2)
            lblPart2_UniqueId3.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 3)
            lblPart2_UniqueId4.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 4)
            lblPart2_UniqueId5.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 5)
            lblPart2_UniqueId6.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 6)
            lblPart2_UniqueId7.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 7)
            lblPart2_UniqueId8.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 8)
            lblPart2_UniqueId9.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 9)
            lblPart2_UniqueId10.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 10)
            lblPart2_UniqueId11.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 11)
            lblPart2_UniqueId12.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 12)
            lblPart2_UniqueId13.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 13)

            Try
                If (RptDetailCusWhere(0).MIDNAME = "-") Then
                    lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).LASTNAME
                Else
                    lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).MIDNAME & " " & RptDetailCusWhere(0).LASTNAME
                End If
            Catch ex As Exception
                lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).LASTNAME
            End Try


            lblPart2_FormalAddr.Text = RptDetailCusWhere(0).FORMALADDR
            If (RptDetailCusWhere(0).FORMALADDR.Length > 50) Then
                lblPart2_FormalAddr.Text = RptDetailCusWhere(0).FORMALADDR.Substring(0, 48)
                lblPart2_FormalAddr0.Text = RptDetailCusWhere(0).FORMALADDR.Substring(48, (RptDetailCusWhere(0).FORMALADDR.Length) - 48)

            End If

            lblPart2_formalPhone.Text = RptDetailCusWhere(0).FORMALPHONE
            lblPart2_formalFax.Text = RptDetailCusWhere(0).FORMALFAX


            If (RptDetailCusWhere(0).OCCUPATIONTYPE = Nothing) Then
                lblPart2_OccupationType.Text = ""
            ElseIf (RptDetailCusWhere(0).OCCUPATIONTYPE = 99) Then
                lblPart2_OccupationType.Text = ""
                lblPart2_OccupationTypeOther.Text = RptDetailCusWhere(0).OCCUPATIONTYPEOTHER
                If (RptDetailCusWhere(0).OCCUPATIONTYPEOTHER.Length > 18) Then
                    lblPart2_OccupationTypeOther.Font.Size = FontSize.Small
                End If

            Else
                lblPart2_OccupationType.Text = clsMasterDropDown.getOfficeOcc_AMLO102(AmloEntity, RptDetailCusWhere(0).OCCUPATIONTYPE)
            End If

            

            lblpart2_WorkAddr.Text = RptDetailCusWhere(0).WORKADDR
            If (RptDetailCusWhere(0).WORKADDR.Length > 37) Then
                lblpart2_WorkAddr.Font.Size = FontSize.Small
            End If

            lblpart2_WorkPhone.Text = RptDetailCusWhere(0).WORKPHONE

            If (RptDetailCusWhere(0).BIZTYPE Is Nothing) Then
                If (RptDetailCusWhere(0).BIZTYPE = 99) Then
                    lblBizType.Text = ""
                    lblBizTypeOther.Text = RptDetailCusWhere(0).BIZTYPEOTHER
                Else
                    lblBizType.Text = clsMasterDropDown.getOfficeType_AMLO102(AmloEntity, RptDetailCusWhere(0).BIZTYPE)
                End If

            End If





            lblPart2_ContactAddr.Text = RptDetailCusWhere(0).CONTACTADDR
            lblPart2_ContactPhone.Text = RptDetailCusWhere(0).CONTACTPHONE
            lblPart2_ContactFax.Text = RptDetailCusWhere(0).CONTACTFAX


            'เป็นการ set type หลักฐาน
            Try
                If Not (RptDetailCusWhere(0).CUSTIDTYPE Is Nothing) Then
                    If (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "1") Then
                        lblPart2_CusType1.Text = "x"
                    ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "6") Then
                        lblPart2_CusType1.Text = "x"
                    ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "3") Then
                        lblPart2_CusType2.Text = "x"
                    ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "4") Then
                        lblPart2_CusType3.Text = "x"
                    ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "5") Then
                        lblPart2_CusType4.Text = "x"
                    ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "99") Then
                        lblPart2_CusType5.Text = "x"
                    Else
                        lblPart2_CusType5.Text = "x"
                        lblPart2_CusTypeOther.Text = clsMasterDropDown.getTypeID_AMLO102(AmloEntity, RptDetailCusWhere(0).CUSTIDTYPE)
                    End If
                End If

            Catch ex As Exception

            End Try





            lblPart2_CusId.Text = RptDetailCusWhere(0).CUSTID
            lblPart2_Evby.Text = RptDetailCusWhere(0).EVBY


            If (RptDetailCusWhere(0).EVGENTEXT = Nothing) Then
                lblPart2_EvGen.Text = ""
            ElseIf (RptDetailCusWhere(0).EVGENTEXT = "-") Then
                lblPart2_EvGen.Text = "-"
            Else
                Try
                    'ChkConvertIntToDate
                    'lblPart2_EvGen.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVGEN)
                    lblPart2_EvGen.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVGENTEXT)
                Catch ex As Exception

                End Try

            End If

            If (RptDetailCusWhere(0).EVEXPIRETEXT = Nothing) Then
                lblPart2_EvExpire.Text = ""
            ElseIf (RptDetailCusWhere(0).EVEXPIRETEXT = "-") Then
                lblPart2_EvExpire.Text = "-"
            Else
                Try
                    'lblPart2_EvExpire.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVEXPIRE)
                    lblPart2_EvExpire.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVEXPIRETEXT)
                Catch ex As Exception

                End Try
            End If


        End If
        RptDetailCusWhere = Nothing
    End Sub

    Private Sub setRptPart3(ByVal RptMaster As IList(Of AMLO102))
        Dim dteDateSpil As String() = Nothing
        Dim blnChkTotaShow As Boolean = True
        Dim testStr As String = ""
        Dim dte_date As Date = Nothing

        Try
          
            dteDateSpil = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).TRANSDATE).Split("/")
            dte_date = RptMaster(0).TRANSDATE
            testStr = dte_date.ToString("MMMM")

            lblTransDate_Day.Text = dteDateSpil(0)
            lblTransDate_Month.Text = testStr
            lblTransDate_Year.Text = dteDateSpil(2)
        Catch ex As Exception

        End Try

        Try
            If Not (RptMaster(0).TRANSTYPE Is Nothing) Then
                If (RptMaster(0).TRANSTYPE < 4) Then
                    If (RptMaster(0).TRANSTYPE = 1) Then
                        lblTransType01.Text = "x"
                    ElseIf (RptMaster(0).TRANSTYPE = 2) Then
                        lblTransType02.Text = "x"
                    ElseIf (RptMaster(0).TRANSTYPE = 3) Then
                        lblTransType03.Text = "x"
                    End If
                Else
                    If (RptMaster(0).TRANSTYPE = 9) Then
                        lblTransType04.Text = "x"
                        lblTransType04_Other.Text = RptMaster(0).TRANSTYPEOTHER
                    Else
                        lblTransType04.Text = "x"
                        lblTransType04_Other.Text = clsMasterDropDown.getTSCTypeName_AMLO102(AmloEntity, RptMaster(0).TRANSTYPE)
                    End If

                End If
            End If

        Catch ex As Exception

        End Try

        If Not (RptMaster(0).ASSETTYPE Is Nothing) Then
            If (RptMaster(0).ASSETTYPE = 1) Then
                lblAssetType1.Text = "x"
            ElseIf (RptMaster(0).ASSETTYPE = 2) Then
                lblAssetType2.Text = "x"
            ElseIf (RptMaster(0).ASSETTYPE = 3) Then
                lblAssetType3.Text = "x"
            ElseIf (RptMaster(0).ASSETTYPE > 3) Then
                lblAssetType4.Text = "x"
                lblAssetType4_Other.Text = RptMaster(0).ASSETTYPEOTHER
            End If
        End If


        lblAssetType_Detail.Text = RptMaster(0).ASSETTYPEDETAIL
        If Not (RptMaster(0).TRANSAMT Is Nothing) Then
            lblTransAmtTotal.Text = insertComma(RptMaster(0).TRANSAMT)
        End If

        If Not (RptMaster(0).CURRENCY = "บาท") Then
            lblCurrency.Text = RptMaster(0).CURRENCY
        End If
        lblTransAmtChar1.Text = RptMaster(0).TRANSAMTCHAR

        lblAccountNo1.Text = RptMaster(0).ACCOUNTNO
        'lblAccountNo1.Text = subStringText(RptMaster(0).ACCOUNTNO, 1)
        'lblAccountNo2.Text = subStringText(RptMaster(0).ACCOUNTNO, 2)
        'lblAccountNo3.Text = subStringText(RptMaster(0).ACCOUNTNO, 3)
        'lblAccountNo4.Text = subStringText(RptMaster(0).ACCOUNTNO, 4)
        'lblAccountNo5.Text = subStringText(RptMaster(0).ACCOUNTNO, 5)
        'lblAccountNo6.Text = subStringText(RptMaster(0).ACCOUNTNO, 6)
        'lblAccountNo7.Text = subStringText(RptMaster(0).ACCOUNTNO, 7)
        'lblAccountNo8.Text = subStringText(RptMaster(0).ACCOUNTNO, 8)
        'lblAccountNo9.Text = subStringText(RptMaster(0).ACCOUNTNO, 9)
        'lblAccountNo10.Text = subStringText(RptMaster(0).ACCOUNTNO, 10)

        lblAccountName.Text = RptMaster(0).ACCOUNTNAME
        If Not (RptMaster(0).ACCOUNTNAME Is Nothing) Then
            If (RptMaster(0).ACCOUNTNAME.Length > 35) Then
                lblAccountName.Font.Size = FontSize.Small
            End If
        End If



        strTempName = ""
        If Not (RptMaster(0).ACCPREFIX = "-" Or RptMaster(0).ACCPREFIX = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).ACCPREFIX
            Else
                strTempName = strTempName + " " + RptMaster(0).ACCPREFIX
            End If
        End If

        If Not (RptMaster(0).ACCFIRSTNAME = "-" Or RptMaster(0).ACCFIRSTNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).ACCFIRSTNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).ACCFIRSTNAME
            End If
        End If

        If Not (RptMaster(0).ACCMIDNAME = "-" Or RptMaster(0).ACCMIDNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).ACCMIDNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).ACCMIDNAME
            End If
        End If

        If Not (RptMaster(0).ACCLASTNAME = "-" Or RptMaster(0).ACCLASTNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).ACCLASTNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).ACCLASTNAME
            End If
        End If
        lblAccCusName.Text = strTempName

        lblAccountRefNo1.Text = RptMaster(0).ACCOUNTREF
        'lblAccountRefNo1.Text = subStringText(RptMaster(0).ACCOUNTREF, 1)
        'lblAccountRefNo2.Text = subStringText(RptMaster(0).ACCOUNTREF, 2)
        'lblAccountRefNo3.Text = subStringText(RptMaster(0).ACCOUNTREF, 3)
        'lblAccountRefNo4.Text = subStringText(RptMaster(0).ACCOUNTREF, 4)
        'lblAccountRefNo5.Text = subStringText(RptMaster(0).ACCOUNTREF, 5)
        'lblAccountRefNo6.Text = subStringText(RptMaster(0).ACCOUNTREF, 6)
        'lblAccountRefNo7.Text = subStringText(RptMaster(0).ACCOUNTREF, 7)
        'lblAccountRefNo8.Text = subStringText(RptMaster(0).ACCOUNTREF, 8)
        'lblAccountRefNo9.Text = subStringText(RptMaster(0).ACCOUNTREF, 9)
        'lblAccountRefNo10.Text = subStringText(RptMaster(0).ACCOUNTREF, 10)

        lblAccountRefName.Text = RptMaster(0).ACCOUNTREFNAME
        If Not (RptMaster(0).ACCOUNTREFNAME Is Nothing) Then
            If (RptMaster(0).ACCOUNTREFNAME.Length > 35) Then
                lblAccountRefName.Font.Size = FontSize.Small
            End If
        End If



        strTempName = ""
        If Not (RptMaster(0).REFPREFIX = "-" Or RptMaster(0).REFPREFIX = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).REFPREFIX
            Else
                strTempName = strTempName + " " + RptMaster(0).REFPREFIX
            End If
        End If

        If Not (RptMaster(0).REFFIRSTNAME = "-" Or RptMaster(0).REFFIRSTNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).REFFIRSTNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).REFFIRSTNAME
            End If
        End If

        If Not (RptMaster(0).REFMIDNAME = "-" Or RptMaster(0).REFMIDNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).REFMIDNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).REFMIDNAME
            End If
        End If

        If Not (RptMaster(0).REFLASTNAME = "-" Or RptMaster(0).REFLASTNAME = "") Then
            If (strTempName = "") Then
                strTempName = strTempName + RptMaster(0).REFLASTNAME
            Else
                strTempName = strTempName + " " + RptMaster(0).REFLASTNAME
            End If
        End If
        lblAccCusRefName.Text = strTempName





        If (RptMaster(0).REFERENCETYPE = Nothing) Then
            lblRelation.Text = ""
        ElseIf (RptMaster(0).REFERENCETYPE = 99) Then
            lblRelation.Text = ""
            lblRelation_Other.Text = RptMaster(0).REFERENCETYPEOTHER
        Else
            lblRelation.Text = clsMasterDropDown.getRelation_AMLO102(AmloEntity, RptMaster(0).REFERENCETYPE)
        End If

        'ส่วนของผู้ได้รับผลประโยชน์

        Try
            strTempName = ""
            If Not (RptMaster(0).GAINPREFIX = "-" Or RptMaster(0).GAINPREFIX = "") Then
                If (strTempName = "") Then
                    strTempName = strTempName + RptMaster(0).GAINPREFIX
                Else
                    strTempName = strTempName + " " + RptMaster(0).GAINPREFIX
                End If
            End If

            If Not (RptMaster(0).GAINFIRSTNAME = "-" Or RptMaster(0).GAINFIRSTNAME = "") Then
                If (strTempName = "") Then
                    strTempName = strTempName + RptMaster(0).GAINFIRSTNAME
                Else
                    strTempName = strTempName + " " + RptMaster(0).GAINFIRSTNAME
                End If
            End If

            If Not (RptMaster(0).GAINMIDNAME = "-" Or RptMaster(0).GAINMIDNAME = "") Then
                If (strTempName = "") Then
                    strTempName = strTempName + RptMaster(0).GAINMIDNAME
                Else
                    strTempName = strTempName + " " + RptMaster(0).GAINMIDNAME
                End If
            End If

            If Not (RptMaster(0).GAINLASTNAME = "-" Or RptMaster(0).GAINLASTNAME = "") Then
                If (strTempName = "") Then
                    strTempName = strTempName + RptMaster(0).GAINLASTNAME
                Else
                    strTempName = strTempName + " " + RptMaster(0).GAINLASTNAME
                End If
            End If
            lblGainFullName.Text = strTempName
        Catch ex As Exception
            Throw ex
        End Try


        If (RptMaster(0).OBJBIZ Is Nothing) Then
            lblObjNameOther.Text = ""
        ElseIf (RptMaster(0).OBJBIZ = 99) Then
            lblObjNameOther.Text = RptMaster(0).OBJBIZOTHER
        Else
            lblObjNameOther.Text = clsMasterDropDown.getObjTypeName_AMLO102(AmloEntity, RptMaster(0).OBJBIZ)
        End If


        'สถาบันการเงินเป็นผู้บันทึกข้อเท็จจริง
        If (RptMaster(0).SAVETYPE = 1) Then
            lblSaveType.Text = "x"

        End If

        'ลูกค้าไม่ลงลายมือชื่อ
        If (RptMaster(0).SIGNTYPE = 0) Then
            lblSignType.Text = "x"
        End If

        Try
            If (RptMaster(0).SAVEDATE Is Nothing) Then
                lblSaveDate.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).SAVEDATE)
            End If

        Catch ex As Exception

        End Try

    End Sub

    Private Function subStringText(ByVal strText As String, ByVal intPosition As Integer) As String
        Try
            Dim strPositionSub As String = ""
            Dim intTextLength As Int32 = 0
            If Not (strText = "") Then
                intTextLength = strText.Length
                If (intPosition < intTextLength) Then
                    strPositionSub = strText.Substring(intPosition - 1, 1)
                ElseIf (intPosition = intTextLength) Then
                    strPositionSub = strText.Substring(intPosition - 1)
                Else
                    strPositionSub = ""
                End If
            Else
                strPositionSub = ""
            End If

            Return strPositionSub
        Catch ex As Exception
            Throw ex
        End Try

    End Function

    Private Function insertComma(ByVal strTransAmt As String) As String
        Dim dcmMoney As Decimal
        Try
            dcmMoney = strTransAmt
            strTransAmt = Decimal.Parse(strTransAmt).ToString("N2")
        Catch ex As Exception
            Throw ex
        End Try
        Return strTransAmt
    End Function

End Class
